package com.in.mobilerechargedth;

import java.util.ArrayList;
import java.util.List;

import com.in.mobilerechargedth.adapter.SecondScreenListViewAdapter;
import com.in.mobilerechargedth.constant.ConstantVariables;


import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;

public class SecondScreenActivity extends BaseActivity {


    ListView lvActions;

    private List<String> listActions;
    Button backbtn;
    String[] actions = new String[] { "UPDATED CHANNELS LIST", "CHANNEL NUMBER OF ALL DTH", "RECHARGE PLANS",
            "CONTACT DETAILS", "TRANSPONDERS DETAILS"};

    int operatorId = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second_screen);
        lvActions = (ListView) findViewById(R.id.lvActions);
        operatorId = (int) getIntent().getLongExtra(ConstantVariables.OPERATOR_ID, 0);
        Log.e("SecondScreenActivity onCreate", "operatorId: " + operatorId);
        listActions = new ArrayList<String>();
        for (int i = 0; i < actions.length; ++i) {
            listActions.add(actions[i]);
        }
        SecondScreenListViewAdapter adapter = new SecondScreenListViewAdapter(SecondScreenActivity.this, listActions);
        lvActions.setAdapter(adapter);
        lvActions.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int position,
                    long arg3) {
                // TODO Auto-generated method stub
                switch (position) {
                    case 0:
                        Intent i = new Intent(SecondScreenActivity.this,
                                ThirdScreenActivity.class);
                        i.putExtra(ConstantVariables.OPERATOR_ID, operatorId + "");
                        Log.e("SecondScreenActivity onCreate onItemClick", "operatorId: " + operatorId);
                        startActivity(i);
                        break;
                    case 1:
                        Intent channel_number_i = new Intent(SecondScreenActivity.this,
                                ChannelNumberSearchScreenActivity.class);
                        channel_number_i.putExtra(ConstantVariables.OPERATOR_ID, operatorId + "");
                        Log.e("SecondScreenActivity onCreate onItemClick", "operatorId: " + operatorId);
                        startActivity(channel_number_i);
                        break;
                    case 2:
                        Intent recharge_plan_i = new Intent(SecondScreenActivity.this,
                                FourthScreenActivity.class);
                        recharge_plan_i.putExtra(ConstantVariables.OPERATOR_ID, operatorId + "");
                        Log.e("SecondScreenActivity onCreate onItemClick", "operatorId: " + operatorId);
                        startActivity(recharge_plan_i);
                        break;
                    case 3:
                        Intent contact_i = new Intent(SecondScreenActivity.this,
                                FifthScreenActivity.class);
                        contact_i.putExtra(ConstantVariables.OPERATOR_ID, operatorId + "");
                        Log.e("SecondScreenActivity onCreate onItemClick", "operatorId: " + operatorId);
                        startActivity(contact_i);
                        break;
                    case 4:
                        Intent transponder_i = new Intent(SecondScreenActivity.this,
                                SixthScreenActivity.class);
                        transponder_i.putExtra(ConstantVariables.OPERATOR_ID, operatorId + "");
                        Log.e("SecondScreenActivity onCreate onItemClick", "operatorId: " + operatorId);
                        startActivity(transponder_i);
                        break;
                }


            }
        });
        backbtn = (Button) findViewById(R.id.backbtn);
        backbtn.setVisibility(View.VISIBLE);
        backbtn.setOnClickListener(this);

        setupAdmob();
        share();
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        super.onClick(v);
        switch (v.getId()) {
        case R.id.backbtn:
            this.onBackPressed();
            break;
        }
    }


}
